<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.hotelManage.vo.Register"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    	String path=request.getContextPath();
    	List<Register> registers=(List<Register>)request.getAttribute("registers");
    
    %>
<table id="tt" class="result-tab" width="100%">
               <tr>
                         <!-- <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th> -->
                  <!--  <th>序号</th> -->
                   <th>序号</th>
                   <th>房间号</th>
                   <th>房型</th>
                   <th>姓名</th>
                   <th>性别</th>
                   <th>联系方式</th>
                   <th>身份证</th>
                   <th>入住时间</th>
                   <th>退房时间</th>
               </tr>
              <%  
              	if(registers!=null){
               for(int i=0;i<registers.size();i++){
               	Register register=registers.get(i);
               	/* out.print(roomType); */
               	%>
               	
               	<tr id="tr<%=register.getId()%>">
               	
                     <%--  <td class="tc"><input data-id="<%=register.getId() %>" class="choose" name="id[]" value="59" type="checkbox"></td> --%>
                      <%-- <td><%=i+1 %></td>  --%>
                      <td><%=i+1 %></td>
                      <td><%=register.getRoom().getNumber()%></td>
                       <td><%=register.getRoom().getRoomtype().getTitle() %></td>
                      <td><%=register.getName() %></td>
                      <td><%=register.getGender()?"男":"女" %></td>
                      <td><%=register.getTelephoneNumber() %></td>
                       <td><%=register.getIdCard()%></td>
                       <td><%=register.getStartTime()%></td>
                       <td><%=register.getEndTime()%></td>
                      
                      <%-- <td class="tt">
                          <a class="link-update" href="<%=path%>/manage/RoomTypeServlet?action=updateInit&id=<%=register.getId()%>">修改</a>
                          <a class="link-del"  id="del<%=register.getId()%>" href="#">删除</a>
                      </td> --%>
                  </tr>
               <% 	
               }
              }
              %>
           </table>
           
             <!-- 显示数字 -->
						<%Pager pager = (Pager)request.getAttribute("pager"); %>
						<div style="text-align: center;">
						<%
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
						</div>
	<!-- 显示数字的结束 -->
	
	<script>
	$(function() {             
		
		$(".no").click(function(){
			/* $(".number").css("color","black");
			$(this).css("color","red"); */
			var cont=<%=pager.getPageNo()%>;
			if(cont<<%=pager.getPageCount()%>){
			cont++;
			}
			$.ajax({
				url:"<%=path%>/manage/RoomHistoryServlet?action=getRegisters",
					data:{pageNo:cont},
						success:function(msg){
							$(".result-content").html(msg);
						}
			})
		})
		$(".ok").click(function(){
			/* $(".number").css("color","black");
			$(this).css("color","red"); */
			var cont=<%=pager.getPageNo()%>;
			if(cont>1){
			cont--;
			}
			$.ajax({
				url:"<%=path%>/manage/RoomHistoryServlet?action=getRegisters",
					data:{pageNo:cont},
						success:function(msg){
							$(".result-content").html(msg);
						}
			})
		})
		
		
		
		
                    
                    $(".link-del").click(function(){
				if(!window.confirm("确定要退房吗")){
					return false;
				}
				var id=$(this).attr("id").substring(3);
				$.ajax({
					url:"<%=path%>/manage/CheckOutServlet?action=delete",
					data:{roomId:id},
					success:function(msg){
						$("#tr"+id).remove();
					}
				});
			})
			})
			</script>
			<script>
			$(".aaa").css("color","red");
			</script>